extends Node2D
@onready var label: Label = $PanelContainer/MarginContainer/Label
@onready var find_player: Area2D = $FindPlayer
@onready var sprite_2d: Sprite2D = $Sprite2D
@onready var sprite_2d_2: Sprite2D = $Sprite2D2
@onready var panel_container: PanelContainer = $PanelContainer
@export_multiline var signText: String
# Called when the node enters the scene tree for the first time.

func _ready() -> void:
	label.text = signText
	find_player.area_entered.connect(on_area_entered)
	find_player.area_exited.connect(on_area_exited)
	panel_container.scale = Vector2.ZERO

func _process(delta):
	panel_container.pivot_offset = Vector2(panel_container.size.x / 2, panel_container.size.y)
	
func on_area_entered(area_2d):
	var tween: Tween = get_tree().create_tween()
	tween.tween_property(panel_container, "scale", Vector2.ONE, .5).set_trans(Tween.TRANS_QUINT)
	sprite_2d.visible = false
	sprite_2d_2.visible = true

func on_area_exited(area_2d):
	var tween: Tween = get_tree().create_tween()
	tween.tween_property(panel_container, "scale", Vector2.ZERO, .5).set_trans(Tween.TRANS_BACK)
	# panel_container.visible = false
	sprite_2d.visible = true
	sprite_2d_2.visible = false
